]> dgit.raspbian.org Git - gnome-shell.git/commit
main: Correct the pointer value of strtab on riscv/mips architectures
authorDaniel van Vugt <daniel.van.vugt@canonical.com>
Thu, 23 Mar 2023 09:51:46 +0000 (17:51 +0800)
committerMarge Bot <marge-bot@gnome.org>
Sat, 5 Aug 2023 19:19:29 +0000 (19:19 +0000)
commit65cde18786e2bea8ffe33317b86182207e419240
tree476295a4b66d9d605f24118fb03fe8ead1cac033
parenta95addd772820918a78eb9b7648909fd67511863
main: Correct the pointer value of strtab on riscv/mips architectures

Glibc defines `d_ptr`/`d_val` to be a relocated address on most
architectures, except for riscv and mips where it is just an offset from
the binary load address. So we need to convert `strtab` from an offset
into a pointer for riscv and mips.

Internally within glibc there is the `D_PTR` macro for doing this, which
relies on private data hidden in an ABI-unstable part of `link_map`. So
we can't use the same conditional logic as glibc does internally.

Our solution is to detect when `strtab` is unreasonably low (below the
address of our binary) and so it must be an unrelocated offset. In that
case we just do the relocation manually.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6528
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2718>
src/main.c